#include<stdio.h>
#include<unistd.h>
#include<sys/wait.h>
#include<sys/types.h>
#include<stdlib.h>

int main()
{
  pid_t id  = fork();
  if(id == 0)
  {
    printf("child run\n");
    char* argv[]={
      "ls",
      "-l",
      "-a",
      NULL
    };
   // char* env[]={
   //   "MYENV = haha",
   //   "MYENV! = hehe",
   //   NULL
   // };
   
    char*env[] = {
        "ls",
        "-a",
        "-l",
        NULL
    };
    //execl("/usr/bin/ls","ls","-a","-l",NULL);
    //execv("/usr/bin/ls",argv);//通过这个argv传给了ls的main函数
    //execlp("ls","ls","-a","-l",NULL);
    //execvp("ls",argv);
    //execle("./myload","myload",NULL,env);
    execvp("ls",argv);
    printf("错误\n");
    exit(1);
  }

  sleep(1);
  printf("father wait begin\n");
  waitpid(-1,NULL,0); 
  //father

  printf("father wait,success\n");


  return 0;
}
